package com.itheima.d2_buffered_stream;

import java.io.*;

public class BufferedInputStreamTest1 {
    public static void main(String[] args) {
        try(
                InputStream is=new FileInputStream("C:\\Users\\dell\\IdeaProjects\\file-io-app\\src\\img.png");
                InputStream bis=new BufferedInputStream(is);
                OutputStream os=new FileOutputStream("C:\\Users\\dell\\IdeaProjects\\file-io-app\\io-app2\\src\\img2.png");
                OutputStream bos=new BufferedOutputStream(os);
        ) {
            byte[] buffer=new byte[1024];

            int len;
            while((len=bis.read(buffer))!=-1){
                bos.write(buffer,0,len);
            }
            System.out.println("复制完成");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
